<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生命周期</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
    <div id="app"></div>
    <script src="../dist/yox.js"></script>
    <script>

        let Custom = {
            propTypes: {
                name: {
                    type: ['string', 'number'],
                    value: 'musicode',
                },
                counter: {
                    type: 'number',
                    value: 0,
                }
            },
            template: `
                <div id="custom-component">
                    {{name}} -> {{counter}}
                </div>
            `
        };

        var instance = new Yox({
            el: '#app',
            data: {
                name: 1,
                counter: 1,
            },
            template: `
                <div id="root">
                    <button on-click="increase('counter')">
                        increase
                    </button>
                    <Custom name="{{name}}" counter="{{counter}}" />
                </div>
            `,
            watchers: {
                counter: function (counter) {
                    console.log(counter)
                }
            },
            components: {
                Custom: Custom
            },
        });

    </script>
</body>
</html>
